#include "stdafx.h"
#include <MyFC/ScrollBar.h>

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

namespace My {

BEGIN_MESSAGE_MAP(ScrollBar, Window<CScrollBar>)
	ON_WM_HSCROLL()
	ON_WM_VSCROLL()
END_MESSAGE_MAP()

ScrollBar::ScrollBar()
{
	memset(&m_Info, 0, sizeof(m_Info));
}

void ScrollBar::SetInfo(SCROLLINFO & info)
{
	m_Info = info;
	if (m_hWnd != 0)
		CScrollBar::SetScrollInfo(&m_Info);
}

void ScrollBar::DoCreateWindow()
{
	m_Style |= WS_DISABLED;
	VERIFY(CScrollBar::Create(m_Style, CRect(), My::Control::GetWindow(), 0));
	CScrollBar::SetScrollInfo(&m_Info);
}

void ScrollBar::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar * pScrollBar)
{
	EventDispatcher::DispatchEvent(HorzScrollEvent(this, nSBCode, nPos));
}

void ScrollBar::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar * pScrollBar)
{
	EventDispatcher::DispatchEvent(VertScrollEvent(this, nSBCode, nPos));
}

} // My
